package com.uzai.console.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 操作日志类型枚举
 * @Auther: liuqi
 * @Date: 2021/8/19 11:22
 * @Description:
 */
public enum OperationTypeEnum {
    QUERY("query", "查询"),
    COPY("copy", "复制"),
    ADD("add", "添加"),
    UPDATE("update", "修改"),
    DELETE("delete", "删除"),
    RESTART("restart", "重启"),
    QUIT("quit", "退出"),
    SENDMESSAGE("sendMessage", "发送消息"),
    REGISTER("register", "注册"),
    DOWNLOAD("download", "下载"),
    UPLOAD("upload", "上传"),
    LOGIN("login", "登录"),
    LAUD("laud","点赞"),
    COLLECT("collect","收藏"),
    BUY("buy", "购买"),
    THROW("throw", "异常"),
    EXPORT("export", "导出"),
    RECORD("export", "备案"),
    ;

    private String key;
    private String desc;

    OperationTypeEnum(String key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static OperationTypeEnum getByKey(String key) {
        if (StringUtils.isBlank(key)) {
            return null;
        }
        for (OperationTypeEnum type: OperationTypeEnum.values()) {
            if (type.getKey().equals(key)) {
                return type;
            }
        }
        return null;
    }
}
